<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld"%>
<%@ taglib prefix="my" uri="/WEB-INF/tld/my.tld"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>${projectName}-编辑</title>
<jsp:include page="/WEB-INF/view/inc/css.jsp"></jsp:include>
</head>
<body class="cld-body">
	<div class="enter-panel ep-xs">
		<input type="hidden" id=aiId value="${param.aiId}"/>
		<input type="hidden" id="aatId" value="${param.aatId}"/>
  		<div class="form-group">
			<label for="name" class="col-sm-4">版本名称 <span class="text-danger">*</span></label>
			<div class="col-sm-8"><input type="text" class="form-control" id="name" placeholder="名称" value="${appApiTest.name}"></div>
		</div>
  		<div class="form-group">
			<label for="remark" class="col-sm-4">备注</label>
			<div class="col-sm-8"><input type="text" class="form-control" id="remark" placeholder="备注" value="${appApiTest.remark}"></div>
		</div>
  		<div class="form-group">
			<label for="code" class="col-sm-4">参考版本</label>
			<div class="col-sm-8"><input type="text" class="form-control" id="copyAatName" placeholder="请选择参考版本" value="${param.copyAatName}"/>
				<input type="hidden" id="copyAatId" value="${param.copyAatId}"/>
			</div>
		</div>
  		<div class="footer-operate">
			<span id="saveMsg" class="label label-danger"></span>
 			<div class="btn-group">
				<button type="button" id="saveBtn" class="btn btn-success enter-fn">保存</button>
			</div>
		</div>
	</div>

	<jsp:include page="/WEB-INF/view/inc/js.jsp"></jsp:include>
	<script type="text/javascript">
	$(function() {

		JUtil.sys.typeahead({
			id: 'copyAatName',
			valueId: 'copyAatId',
			url: webroot + '/appApiTest/f-json/findSearch'
		});
		
		
		$('#saveBtn').click(function() {
			var saveMsg = $('#saveMsg').empty();
			var aiId = $('#aiId');
			
			var name = $('#name');
			if(JUtil.isEmpty(name.val())) {
				saveMsg.append('请输入名称');
				name.focus();
				return;
			}

			JUtil.ajax({
				eventId: 'saveBtn',
				url: '${webroot}/appApiTest/f-json/save',
				data: {
					aatId: $('#aatId').val(),
					aiId: aiId.val(),
					name: name.val(),
					remark: $('#remark').val(),
					copyAatId: $('#copyAatId').val()
				},
				success : function(json) {
					if (json.code === 0) {
						saveMsg.attr('class', 'label label-success').append('保存成功');
						setTimeout(function() {
							parent.apiAutoTestInfo.loadInfo();
							parent.apiAutoTestDtlInfo.aatId = undefined;
							parent.dialog.close();
						}, 800);
					}
					else if (json.code === -1)
						saveMsg.append(JUtil.msg.ajaxErr);
					else
						saveMsg.append(json.message);
				}
			});
		});
	});
	</script>
</body>
</html>